"Choose Your Own Object - A Tutorial on Traps"  by Komag, for Thief 2

So, you want to learn traps?  Haha, you'll know traps after this!  This tutorial and demo will illustrate the usage and purpose of various traps in dromed.  You will end up with a system of narrowing down your choices of which object you want to appear.  This could be used in any number of situations, combining with questvartriggers and such for interesting results.  In this demo you'll just get to see the final object chosen.  We will also be building in some redundancy in the system so that pressing the wrong buttons and the wrong times will do no harm :-).

FYI, the demo mission that accompanies this tutorial has a few extra things in it that are not covered by the tutorial - they are unnecessary but nice additions that you can figure out on your own if you want to.

     I. THE TRAPS

First of all, here is a list of the traps used in this tutorial/demo and their basic purpose/description: RelayTrap, RevertTrap, RequireAllTrap, Inverter, DestroyTrap, CreateTrap.

RelayTrap:  You can link to this with as many ControlDevice links as you want (one each from different sources) and then send out as many other ControlDevice links from this as you want (one each to different other things)

RevertTrap:  You can link to this with a ControlDevice and then link it to another thing with ControlDevice.  After a moment (the length of which you adjust) the revert trap will then send out an opposite signal.  So if you linked a button to the revert trap, and then the revert trap to a light (which is set up to be an animlight), then pressing the button would send and on signal to the reverter, which would send an on signal to the light, turning it on.  Then a moment later the revert trap would send and off signal to the light, turning it back off.

RequireAllTrap:  You can link a number of things to this, and then link this to other things.  It will only send the on signal to the other things, however, when ALL of the first things have sent their signals to it.  So if you linked three buttons to the require all trap, and then linked the require all trap to a light, you would have to press all three buttons before the light would go on.

Inverter:  You can link to this and it will then send the opposite signal to whatever you link it to.  So if you linked a button to the inverter and then linked the inverter to a light, pressing the button would turn the light off (if the light is already on) instead of turning it on (as a button linked directly to a light would).

DestroyTrap:  You can link things to this and then link it to things which it will kill!  So, you can link a button to a destroy trap, and link the destroy trap to some other relay trap in another circuit, and pressing the button will destroy that other relay trap thus cutting off whatever that other relay trap was linked to.

CreateTrap:  These are activated by ControlDevice links from other things.  You link a create trap to the object you want to create with a Contains link.  First you have to actually make the object in dromed.  Put the object somewhere off to the side.  Put the create trap where you want the object to appear.  Then link the create trap to this object with a contains link.  Then you could link a button to the create trap (with a ControlDevice link) and when you press the button the object will apear where the destroy trap is.

Well be using a LOT of buttons, traps, and links, so if you're new to all that I'll try to walk you through it easily.  If you've used traps and such before then this should be relatively straightforward :-).

     II. THE PLAN

We're going to be using all these traps and other things to set up a "choose your own object" game.  You'll start out with 8 possibilities, and each choice you make narrows the field in half.  So you make three choices, each time choosing the right side or the left side, with the final choice between the last two possibilities.  When you make the last choice, your object appears and you're done.  It may seem somewhat pointless, but you could use this in missions in various ways which I'll leave up to you.

In thinking ahead we want to set everything up so that the player can't mess it up.  This accounts for most of the links we'll be creating.  If the player would just carefully make each choice, in order, without trying to press the wrong buttons, we could do it all very much simpler.  But that is not how life works nor how we should plan a mission.

One consideration is that when the player chooses in each of the three choices, we want the other choice (the one he didn't make each time) to instantly become no longer available.  In this demo we aren't going to remove the buttons, but we'll just make them inoperable after the choices have been made, by removing the traps which the buttons link to.  So, for example, in the first choice when you choose either the left 4 or the right 4, lets say the player chooses the left 4 (he presses the left button).  Not only will this do various things controlled by pressing the left button, but it will also delete the ability of the right button to do anything after that.

We also need to set things up so that the player cannot skip to the second or third choice before doing the first one.  In this case we will be using require all traps on the later buttons.  Part of what will happen during the earlier choices is that they will send signals to the requireall traps near the buttons in the later choices, which buttons will remain inoperable until you rightfully proceed to them as opposed to skipping to them.

Relating to this same issue of skipping ahead, the require all traps solution isn't good enough.  The player may still press these buttons early and partially fulfil the require all trap associated with them, so that when the rest the require all trap is fulfilled it will send out its signal without having to press the button again.  To solve this we will place inverter traps inbetween the buttons and the requireall traps so that an early button press will be negated moments later and will only be effective when the time is appropriate.

There are other various considerations to take into account when planning a system/setup as we are going to create, but with some experience they should come to you readily, and I won't go into any more of them at this time :-).

     III. SETTING THINGS UP

Of course, you should have a base mission all ready to go, with a basic room or two with the proper scripts added and such so that everything works normally.  It is recommended to have such a base mission always ready to start new missions with and demos and such.

1.  So, to start out, make 8 pedestals for the objects.  Make them 4 unit cubes (solid) sitting on the ground.  Put them all in a row on the side of the room.  Then put 2 unit cubes (air) inside each pedestal to make them all hollow in the middle.  We'll be using this space purely as a convenience.

2.  Make a "RustGasCan" (physical-Treasure-QuestItems-RustGasCan) and copy it for a total of 8 rust gas cans.  Place them in the middle of each pedestal in the hollow spots.

3.  Make a "HangingSpot" (physical-Lights-lanterns-HangingLantern-HangingSpot) above the first pedestal.  Go into its properties and Add-S-Scripts-"AnimLight" (no quotes.  Then, Add-Renderer-Anim Light- and set the settings.  Put the first one on "Minimum Brightness", then the rest something like 63,63,150,15,0,0,check,leave the rest 0 or blank.  Then, edit the "Light" section under Renderer and change the light from 125 (I think) down to 0.  Now, copy this adjusted light and make 8 of them total, one over each pedestal.

4.  Make a long counter in front of all the pedestals running along in the same direction as the row of pedestals. On this counter we'll put all the buttons to control things. We want to be able to see the pedestals behind the counter, so don't put the counter right next to the pedestals, but out a ways so you can see everything.

5.  Make a "Button" (physical-Gizmo-Switches-Buttons-Button) and turn it so it sits flat on the counter near the edge further away from the pedestals.  That way when we stand on that side of the counter, the button is close to us and we can see all the pedestals on the other side.  Also, put it near the left side of the counter, left as in when you are behind the counter ready to use the button, facing all the pedestals.  Copy this button and make a total of 7 buttons.  Arrange them so that the first one on the left is alone, and the other 6 are in pairs of 2 side by side, further and further to the right.  You should have 4 basic spots now along the counter - the left spot has one button, the next spot has 2 buttons side by side, then next spot also has 2, and finally the last spot on the right also has 2.

     IV. MAKING THE TRAPS

Now we'll make all the traps (41), after which we'll put in all the links (over 100!).

1.  Make a "RevertTrap" (fnord-TrapTrig-RevertTrap).  Open the propertied of the revert trap and Add-Script-Timing- and put in "300" (no quotes, of course). Click Done.  Copy the revert trap for a total of 6 revert traps. Place them next to the 6 buttons which are in pairs, leaving alone the one lone button on the left.  Place them so that it is clear to you which revert trap goes with which button.

2. Make a "RequireAllTrap" (fnord-TrapTrig-RequireAllTrap) and copy it of a total of 6 require all traps.  Like the revert traps above, place the require all traps near the 6 paired buttons, perhaps right next to each revert trap.  Place them so that it is very clear to you which require all trap goes with which button/revert trap.

3.  Make a "RelayTrap" (fnord-TrapTrig-RelayTrap) and copy it for a total of 9 relay traps.  Place 7 of them each next to a button (this time include the leftmost lone button as well), so that it is clear to you which relay trap goes with which button.  Now you have 2 relay traps left.  Place one of them inbetween the leftmost pair of buttons (ignoring the single button on the very left), and place the other of them inbetween the middle pair of buttons.  In other words, In the first spot on the counter, on the left, you have just 1 relay trap.  In the second spot you should now have 3 relay traps, one for each button and one inbetween.  In the third spot on the counter you should also have three relay traps similarly laid out.  And in the fourth spot you have just two relay traps, one for each button, but no relay trap inbetween.

By now you should be realizing that trap placement needs to be tidy so that you can keep track of which traps connect to which other traps and buttons when we start making the links later on.

4.  Make an "Inverter" (fnord-TrapTrig-Inverter) and copy it for a total of 6 inverters.  Like the require all traps and the revert traps above, place the inverters near the 6 paired buttons, perhaps right next to each relay trap (but not the 2 relay traps that are inbetween).  Place them so that it is very clear to you which require all trap goes with which button/revert trap/require all trap/relay trap.  Again, there is no inverter to go along with the first lone button on the left.

5.  Make a "DestroyTrap" (fnord-TrapTrig-DestroyTrap) and copy it for a total of 6 destroy traps.  Place them similarly to how you placed the inverters, skipping the one button and its relay trap on the left.

6.  Finally, make a "CreateTrap" (fnord-TrapTrig-CreateTrap) and copy it for a total of 8 create traps.  Place them on top of each pedestal, up just a bit so they are not exactly sitting right on top of each pedestal but floating just a little.

     V. ADDING THE LINKS

Now for all the links!  There are a lot (over 100), so follow them carefully and make sure you put in the right flavors all along the way (mostly ControlDevice).  Save often too, because a bad link can crash dromed and you'd have to start over!

For each link to add below, keep in mind a few things.  When something is going to be controlling something else, the first thing is linked to the second thing with the flavor "ControlDevice" from it (the first thing) to the second thing.  There are two ways to make the same one link, either making it forwards or making it backwards.  Sometimes it is quicker to do it one way, sometimes the other.  Whichever way you do it, dromed will automatically put in the other direction link, so that if you always did backwards links dromed would always automatically put in the corresponding forwards links.  If you don't want to get confused, however, and you are unsure about forwards vs backwards links, then always do them forwards and just ignore the backwards links that dromed will automatically put in :-).

1.  Link each button to it's corresponding revert trap (the first lone button on the left has no revert trap, so ignore that one).  Here's how to do the first one, and you can do the rest.  Select the revert trap and make a note of its number (the number in paretheses () next to where it says "A RevertTrap" at the bottom of dromed).  Now Select the button you are going to link and click on "Links" at the bottom of dromed (under "Properties").  In the Links window click Add.  In the Flavor field choose ControlDevice (remember, not ~ControlDevice, as the ~ denotes a backwards link).  In the From field put in the number of the button (the number in paretheses () next to where it says "A Button" at the bottom of dromed).  In the To field put the number of the revert trap.  Click OK.  You should see the link information now in the Links window.  Click OK.
  
Now you can select the revert trap, open its Links window, and you'll see the link information that shows a backwards link the button.  If you wanted to, you could have added this backwards link instead of adding the forwards link from the button's Link window, and dromed would have automatically created that forwards link instead of automatically creating this backwards link.  If the forwards/backwards think just confused you, then ignore all the backwards links from now on and forget what I just said! :-)

From now on I'll go into much less detail on how to actually add the links.  Always use ControlDevice (forwards, without the ~) links unless otherwise told.

2. Link each revert trap to its corresponding require all trap.

3. Link each require all trap to its corresponding relay trap.  Remember to ignore for now the relay trap next to the lone button on the left, and ignore the two relay traps which are in the inbetween positions.

3. Link each relay trap to its corresponding inverter.  Again, just link the relay traps that you linked in the previous step, ignoring the other three relay traps.

4. Link those same relay traps to their corresponding destroy traps.

Okay, that was the easy part!  Be very careful throughout the following links.  Since these are more complex, I going to explain them using a simple code (perhaps I should have used this earlier as well).  I'm going to label the 6 paired buttons as the letters A,B,C,D,E,and F.  This is ignoring the first single button on the left, but preceeds from that button left to right (remember, the "left to right" is relative to you standing on the opposite side of the counter as the pedestals are on, and you facing the counter and the pedestals).  So, in the first spot on the counter on the left there is one button.  In the next spot over there are two buttons, labelled A and B.  In the next spot there are two buttons labelled C and D.  And in the final spot on the right there are the last two buttons I'm labelling E and F.

5. Link each destroy trap to it's corresponding revert trap.  So for button A, select the destroy trap corresponding to button A (destroy trap A) and add a ControlDevice link from the destroy trap to revert trap A.

6. Link each destroy trap to the relay trap of the opposite button in the pair.  So, for the first pair A and B, link the destroy trap A to relay trap B and vice versa.  So, select destroy trap A (the destroy trap corresponding with button A) and add a ControlDevice link from it to relay trap B (the relay trap corresponding with button B)

Now I need to create some links for the CreateTraps and the HangingSpots, so I'll label them too.  When you are behind the counter facing the wall with the pedestals, the pedestals from left to right will be 1,2,3,4,5,6,7,8.  Each pedestal has its corresponding HangingSpot, CreateTrap, and RustGasCan.  Simple enough, eh? :-)

7. Link the relay trap which is next to the first single button on the left to all 8 HangingSpots (1 through 8).

8. Link that same relay trap (next to the first single button on the left side of the counter) to all 6 require all traps (A through F).

9. Link inverter A to HangingSpots 5,6,7,and 8.  Link inverter B to HangingSpots 1,2,3,and 4.

10. Link inverter C to HangingSpots 3,4,7,and 8.  Link inverter D to HangingSpots 1,2,5,and 6.

11. Link inverter E to HangingSpots 2,4,6,and 8.  Link inverter F to HangingSpots 1,3,5,and 7.

12. Link relay trap A to the relay trap which is inbetween buttons A and B.  Link relay trap B to this same inbetween relay trap as well.

13. Link the relay trap inbetween buttons A and B (the one we just linked to above) to require all traps C,D,E,and F.

14. Link relay trap C to the relay trap which is inbetween buttons C and D.  Link relay trap D to this same inbetween relay trap as well.

15. Link the relay trap inbetween buttons C and D (the one we just linked to above) to require all traps E and F.

16. Link destroy trap A to the relay trap next to the first single button on the left.  Link destroy trap B to that same relay trap as well.

17. Link destroy trap A to create traps 5,6,7,and 8.  Link destroy trap B to create traps 1,2,3,and 4.

18. Link destroy trap C to create traps 3,4,7,and 8.  Link destroy trap D to create traps 1,2,5,and 6.

19. Link relay trap E to create traps 1,3,5,and 7.  Link relay trap F to create traps 2,4,6,and 8.

20. Link all the create traps with a Contains link (not a ControlDevice link this time) to their corresponding rust gas cans.


That's it!!!  Wow, hopefully you got all those links properly in place.